const baseUrl = 'https://wesl.nekolab.tech/sp'
const request = ({ method = 'get', url, data, header }) => {
  return new Promise((resolve, reject) => {
    uni.request({
      method: method,
      url: baseUrl + url,
      data: data || '',
      header: header || '',
      dataType: 'json',
    }).then((response) => {
      setTimeout(function() {
        uni.hideLoading();
      }, 200);
      response = response || '';
      let [error, res, reason] = response;
      resolve(res.data);
    }).catch((error) => {
      error = error || '';
      let [err, res, reason] = error;
      reject(err)
    })
  });
}
export default request
